//配置路由用的类
import {createRouter, createWebHistory} from "vue-router"
/* Layout */
// import Layout from '../layout/Admin.vue';
// import Temp from '../layout/Temp.vue';
// const isProduction = process.env.NODE_ENV === 'production';
let redirectUrl:String = '/'
// if(!isProduction){
//   redirectUrl = '/demo/devDemo'
// }
const routers:any = [
    {
      path: '/',
      name: '',
      meta: { title: "示例示例", icon: '&#xe6d2;' },
      component: ()=>import('@/views/index.vue'),
      children: []
    },
    {
      path: '/m3u8',
      name: 'm3u8',
      meta: { title: "示例示例", icon: '&#xe6d2;' },
      component: ()=>import('@/views/m3u8Page.vue'),
      children: []
    },
//   {
//     path: '/error',
//     name: 'error',
//     meta: { title: "错误" },
//     component: Layout,
//     children: [
//       {
//         path: '404',
//         name: '404',
//         component: () => import('@/views/error/404.vue'),
//         meta: { title: '404' },
//       }
//     ],
//     hidden: true
//   },
  {path: '/:pathMatch(.*)*', redirect: redirectUrl, hidden: true}
]

//定义路由
const publicpath = import.meta.env.VITE_PUBLICPATH;
const router = createRouter({
  history: createWebHistory(publicpath),
  routes: routers,
  scrollBehavior: (to, from, savePosition) => {
    if (savePosition) {
      return savePosition
    } else {
      return {left: 0, top: 0}
    }
  },
});

export default router
